package com.example.teachmall4.service;
import com.example.teachmall4.entity.Goods;
import com.example.teachmall4.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class GoodsService {
    //调用mapper方法，拿到所有的商品数据
    @Autowired
    private GoodsMapper goodsMapper;
    //返回所有的商品数据
    public List<Goods> selectAll() {
        return goodsMapper.selectAll();
    }
    //返回所有的最新商品数据
    public List<Goods> selectAllNew() {
        return goodsMapper.selectAllNew();
    }
    public List<Goods> findByPage(int page, int pageSize) {
        int offset = (page - 1) * pageSize;
        return goodsMapper.selectByPage(offset, pageSize);
    }
    public long count() {
        return goodsMapper.count();
    }
}
